﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartRFIDSystem.dao
{

    public class DbUtil
    {
        //连接对象
       private MySqlConnection conn = null;

        //语句执行对象
        private MySqlCommand comm = null;
        //语句执行结果数据对象
        private MySqlDataReader dr = null;

        public  void getcon()
        {
            string M_str_sqlcon = "server=localhost;user id=root;password=3027689312a;database=contactssystem";
            conn = new MySqlConnection(M_str_sqlcon);
            try
            {
                conn.Open();
                MessageBox.Show("数据库连接成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败");
            }

        }
        public  void closecon()
        {
            try
            {
                conn.Close(); 
            } catch 
            {

            }
        }

    }
}
